Simple
Free
Flexible
Trendy
Open a new R script file (File > New File > R Script)
Console
Console
Script
Console
Script
Tracking panel
Console
Script
Tracking panel
Multipurpose panel
Check files in your computer, see plots, manage packages, read help section of a function.
Console
Script
Tracking panel
Multipurpose panel
Caution
Write everything you do in scripts to avoid loosing your work.
Tip
Solving errors is an important skill to learn.
Tip
Comment your script to help you remember what you have done.
Complex type
Complex type
Note
These are the basic complex types. It exists a lot of different complex objects which mix all these basic objects.
if, else, TRUE, FALSE)valid.name, valid_name, valid2name3valid name, valid-name, 1valid2name3Tip
Avoid random names such as var1, var2. Use significant names: gene_list, nb_elements
The name of the object followed by the assignment symbol and the value.
You can use operators on objects to modify them. Depending on the object format, operators have different behaviors and some are forbidden.
+-*/^ or **%/%%%Exercise
Correction
Exercise
Try to raise errors using operators.
function_name(object, parameter1 = ..., parameter2 = ...)help, ? or F1)Note
Some functions are in the default installation of R. Other functions come from packages. You can also create your own functions.
vector construction
c() Concatenate function1:10 Vector with numbers from 1 to 10vector construction
c() Concatenate function1:10 Vector with numbers from 1 to 10Extra
seq Create a sequence of numbersrep Repeat elements several timesrunif Simulate random numbers from Uniform distribution. Same for rnorm, rpois…Instructions
vector with 7 numeric valuesvector with 7 character valuesManipulation
Using index/position between []
Characterization
length() Number of elements in the vectornames() Get or set the names of the vector’s valueManipulation
sort() Sort a vectorsample() Shuffle a vectorrev() Reverse a vectorExtra
sort()/sample() Explore extra parametersorder() Get the index of the sorted elementsExploration
head()/tail() Print the first/last valuessummary() Summary statisticsmin()/max()/mean()/median()/var() Minimum, maximum, average, median, variancesum Sum of the vector’s valuesExtra
log/log2/log10 Logarithm functionssqrt Square-root functionArithmetic operators
Instructions
runif or rnorm)hist function